<?php
/**
 * User:帅帅吴
 * Time: 2018/7/27 17:45
 */

namespace app\admin\model;


class ShopHorn extends DataBase
{
    protected $name = 'shop_horn';
    protected $autoWriteTimestamp = true;

    public function getUpdateTimeAttr($value)
    {
        return date('Y-m-d H:i:s', $value);
    }

    public function getHornTypeAttr($value)
    {
        $status = [1 => '小喇叭', 2 => '大喇叭',3=>'其他'];
        return $status[$value];
    }

    public function getTypeAttr($value)
    {
        $status = [1=>'普通',2=>'非卖品'];
        return $status[$value];
    }

    public function getIsPutawayAttr($value)
    {
        $status = [1 => '否', 0 => '是'];
        return $status[$value];
    }


    public function getDataList()
    {
       $page_config = array(
           'page' => input('offset',1),
           'limit' => input('limit',10)
       );
       $order = input('sort','sort').' '.input('order','desc');
       $where = [];
       if(!empty(input('start_time')) && !empty(input('end_time'))){
           $start = strtotime(input('start_time')); $end =strtotime(input('end_time'));
           $where[] =['create_time','>=',$start];
           $where[] = ['create_time','<',$end];
       }
       if(!empty(input('key')) && !empty(input('value'))){
            $where[] = [input('key'),'=',input('value')];
       }
       $data = $this->where($where)->order($order)->paginate($page_config);
       return $data;
    }
}